{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b4a2419d-1769-446c-b460-6342c2332d43",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Jupyter-Notebook-732-Crawler-Collect-ollama-com.ipynb\n",
    "# Create by GF 2025-03-19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "76b88109-f263-4f93-abb3-43830705a14a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import GF_PY312_CLASS_Crawler_by_BS4\n",
    "# ..................................................\n",
    "Crawler = GF_PY312_CLASS_Crawler_by_BS4.Crawler()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d58139f0-1251-4fc7-ab1b-8a83e1f83764",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'col_1': ['general.architecture', 'general.file_type', 'qwen2.attention.head_count', 'qwen2.attenti ...\n"
     ]
    }
   ],
   "source": [
    "Crawler.URL = \"https://ollama.com/library/qwen2.5-coder:32b/blobs/ac3d1ba8aa77\"\n",
    "Crawler.Cap_List_by_Ele_S = \"general.architecture\"\n",
    "Crawler.Cap_List_by_Ele_E = \"tokenizer.ggml.tokens\"\n",
    "Result_Metadata = Crawler.ollama_com_Collect_Metadata_20250301()\n",
    "# ..................................................\n",
    "print(str(Result_Metadata)[0:100], \"...\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d21249f8-6220-4e9d-ac80-d4bb3bff5a60",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'col_1': ['token_embd.weight', 'blk.0.attn_k.bias', 'blk.0.attn_k.weight', 'blk.0.attn_norm.weight' ...\n"
     ]
    }
   ],
   "source": [
    "Crawler.URL = \"https://ollama.com/library/qwen2.5-coder:32b/blobs/ac3d1ba8aa77\"\n",
    "Crawler.Cap_List_by_Ele_S = \"token_embd.weight\"\n",
    "Crawler.Cap_List_by_Ele_E = \"output_norm.weight\"\n",
    "Result_Tensor = Crawler.ollama_com_Collect_Tensor_20250301()\n",
    "# ..................................................\n",
    "print(str(Result_Tensor)[0:100], \"...\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e9d9629b-6547-4f6a-a3e2-7ad301dae90f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "general.architecture                               qwen2\n",
      "general.file_type                                  Q4_K_M\n",
      "qwen2.attention.head_count                         40\n",
      "qwen2.attention.head_count_kv                      8\n",
      "qwen2.attention.layer_norm_rms_epsilon             1e-06\n",
      "qwen2.block_count                                  64\n",
      "qwen2.context_length                               32768\n",
      "qwen2.embedding_length                             5120\n",
      "qwen2.feed_forward_length                          27648\n",
      "qwen2.rope.freq_base                               1e+06\n",
      "tokenizer.ggml.add_bos_token                       false\n",
      "tokenizer.ggml.bos_token_id                        151643\n",
      "tokenizer.ggml.eos_token_id                        151645\n",
      "tokenizer.ggml.merges                              [Ġ Ġ, ĠĠ ĠĠ, i n, Ġ t, ĠĠĠĠ ĠĠĠĠ, ...]\n",
      "tokenizer.ggml.model                               gpt2\n",
      "tokenizer.ggml.padding_token_id                    151643\n",
      "tokenizer.ggml.pre                                 qwen2\n",
      "tokenizer.ggml.token_type                          [1, 1, 1, 1, 1, ...]\n",
      "tokenizer.ggml.tokens                              [!, \", #, $, %, ...]\n"
     ]
    }
   ],
   "source": [
    "for c1, c3 in zip(Result_Metadata[\"col_1\"], Result_Metadata[\"col_3\"]):\n",
    "    print(\"%-50s %s\" % (c1, c3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f44782e0-317d-4b00-b3f1-1ec39b105bba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "token_embd.weight                                  Q4_K                      [5120, 152064]\n",
      "blk.0.attn_k.bias                                  F32                       [1024]\n",
      "blk.0.attn_k.weight                                Q4_K                      [5120, 1024]\n",
      "blk.0.attn_norm.weight                             F32                       [5120]\n",
      "blk.0.attn_output.weight                           Q4_K                      [5120, 5120]\n"
     ]
    }
   ],
   "source": [
    "counter = 1\n",
    "stop_point = 1\n",
    "# ..................................................\n",
    "for c1, c2, c3 in zip(Result_Tensor[\"col_1\"], Result_Tensor[\"col_2\"], Result_Tensor[\"col_3\"]):\n",
    "    print(\"%-50s %-25s %s\" % (c1, c2, c3))\n",
    "    if (counter >= 5 and stop_point == 1): break\n",
    "    counter = counter + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0c7ed7be-730b-456d-9934-61c54e490a4c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
